package rpcxusage

import (
	"context"
	"gitee.com/xcy871622040/gameframe/cluster"
	"gitee.com/xcy871622040/gameframe/cluster/rpcx"
	"github.com/smallnest/rpcx/client"
)

var (
	XClient rpcx.XClient
)

// InitRpcxUsage 初始化rpc客户端
func InitRpcxUsage(ctx context.Context, selectByDefind rpcx.Filter) {
	initXService(ctx)
	XClient = rpcx.NewXClient(
		cluster.App().Runtime.Discovery,
		rpcx.WithFailMode(client.Failtry),
		rpcx.WithSelectMode(
			client.SelectByUser,
			func(customized *rpcx.Customized) {
				customized.SetFilterFunc(selectByDefind)
			}),
		rpcx.WithServerMessageChan(returned.conn),
	)
}
